package mumu.android;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import mumu.android.app.BroadCast1;
import mumu.android.app.ZZdemoActivity;
import mumu.android.app.bindservier;
import mumu.android.app.event1;
import mumu.android.app.event2;
import mumu.android.app.fileEncry;
import mumu.android.app.fileEncry2;
import mumu.android.app.fileEncry3;
import mumu.android.app.filesqlite;
import mumu.android.app.observeractivity;
import mumu.android.app.simservier;
import mumu.android.monitoring.BatteylevelActivity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class AppActivity extends ListActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setListAdapter(new SimpleAdapter(this, getData(), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 }));
		getListView().setTextFilterEnabled(true);
	}

	protected List getData() {
		List<Map> myData = new ArrayList<Map>();
		addItem(myData, "BroadCast1", new Intent(this, BroadCast1.class));
		addItem(myData, "simservier", new Intent(this, simservier.class));
		addItem(myData, "bindservier", new Intent(this, bindservier.class));
		addItem(myData, "event1", new Intent(this, event1.class));
		addItem(myData, "event2", new Intent(this, event2.class));
		addItem(myData, "observer", new Intent(this, ZZdemoActivity.class));

		addItem(myData, "filesqlite", new Intent(this, filesqlite.class));

		addItem(myData, "fileEncry", new Intent(this, fileEncry.class));
		addItem(myData, "fileEncry2", new Intent(this, fileEncry2.class));
		addItem(myData, "fileEncry3", new Intent(this, fileEncry3.class));
		addItem(myData, "observeractivity", new Intent(this, observeractivity.class));
		addItem(myData, "BatteylevelActivity", new Intent(this, BatteylevelActivity.class));

		return myData;
	}

	protected void addItem(List<Map> data, String name, Intent intent) {
		Map<String, Object> temp = new HashMap<String, Object>();
		temp.put("title", name);
		temp.put("intent", intent);
		data.add(temp);
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		Map map = (Map) l.getItemAtPosition(position);
		Intent intent = (Intent) map.get("intent");
		startActivity(intent);
	}
}
